﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FortuneHeavan.Game.DAL;
using FortuneHeavenCommon.DataMap;

namespace FortuneHeavenBAL
{
    public class AccountsInfoBO
    {
        public AccountsInfoDAL _acountDAL;
        public AccountsInfoBO()
            : base()
        {
            _acountDAL = new AccountsInfoDAL();
        }

        public AccountsInfo CheckUserPwd(string user, string password)
        {
            return _acountDAL.CheckUserPwd(user, password);
        }

        public bool CheckExist(string user)
        {
            return _acountDAL.CheckExist(user);
        }

        public AccountsInfo GetLightAcountInfor(string user)
        {
            return _acountDAL.GetLightAcountInfor(user);
        }

        public List<AccountsInfo> GetUserInfor(int page, int size, string username,string spread)
        {
            if (!string.IsNullOrEmpty(username) && username.Trim() == "")
            {
                username = "";
            }
            if (!string.IsNullOrEmpty(spread) && spread.Trim() == "")
            {
                spread = "";
            }

            return _acountDAL.GetUserInfor(page, size, username.Trim(),spread.Trim());
        }

        public int GetTotalSize(string username, string spread)
        {
            if (!string.IsNullOrEmpty(username) && username.Trim() == "")
            {
                username = "";
            }
            if (!string.IsNullOrEmpty(spread) && spread.Trim() == "")
            {
                spread = "";
            }

            return _acountDAL.GetTotalSize(username.Trim(), spread.Trim());
        }
        public List<AccountsInfo> GetTopShortInfor(int top)
        {
            return _acountDAL.GetTopShortInfor(top);
        }


        public void Delete(List<int> userids)
        {
            _acountDAL.Delete(userids);
        }

        public void Start(List<int> userids)
        {
            _acountDAL.Start(userids);
        }

        public void Stop(List<int> userids)
        {
            _acountDAL.Stop(userids);
        }

        public AccountsInfo GetAcount(int id)
        {
           return  _acountDAL.GetAcount(id);
        }

        public void Save(AccountsInfo infor)
        {
            _acountDAL.Save(infor);
        }
        public void Add(AccountsInfo infor)
        {
            _acountDAL.Add(infor);
        }

        public List<AccountsInfo> GetMemberUserInfor(int page, int size, string username, int type)
        {
            if (!string.IsNullOrEmpty(username) && username.Trim() == "")
            {
                username = "";
            }
            return _acountDAL.GetMemberUserInfor(page, size, username, type);
        }

        public int GetMemberTotalSize(string username, int type)
        {
            if (!string.IsNullOrEmpty(username) && username.Trim() == "")
            {
                username = "";
            }
            return _acountDAL.GetMemberTotalSize(username, type);
        }

        public void SetNewPassword(int userid, string password)
        {
            _acountDAL.SetNewPassword(userid, password);
        }
        public void UpdateGender(int gender, int userid)
        {
            _acountDAL.UpdateGender(gender, userid);
        }

        /// <summary>
        /// 注册帐号
        /// </summary>
        /// <param name="infor"></param>
        /// <param name="error"></param>
        /// <returns></returns>
        public bool RegisterNameAcount(AccountsInfo infor, ref string error)
        {
            return _acountDAL.RegisterNameAcount(infor, ref error);
        }

        public List<AccountsInfo> GetSpreadList(int page, int size, int SpreaderID)
        {
            return _acountDAL.GetSpreadList(page, size, SpreaderID);
        }

        public int GetSpreadTotalSize(int SpreaderID)
        {
            return _acountDAL.GetSpreadTotalSize(SpreaderID);
        }
    }
}
